from openai import OpenAI
from config.config import OPENAPI_API_KEY_3, OPENAPI_API_BASE_3

## 初始化openai的参数
client = OpenAI(
    api_key=OPENAPI_API_KEY_3,
    base_url=OPENAPI_API_BASE_3
)


def generateWeatherReport(city):
    messages = [
        {
            "role":"system",
            "content":f"你是一个天气预报播报员，模拟即刻，控制在20字以内"
        },
        {
            "role":"user",
            "content":f"介绍一下{city}的天气"
        }
    ]

    response = client.chat.completions.create(
        model="gpt-3.5-turbo-0125",
        messages=messages,
        temperature=0.9,  ## float 控制输出“随机性”（创意 vs 稳定）
        max_tokens=400,  ## int 限制返回结果的最大长度
    )
    print(response.choices[0].message.content)
    return {"message": response.choices[0].message.content}
